package com.jee.mql.web.actions;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jee.mql.business.UserManager;
import com.jee.mql.model.User;

public class UserAction {

	private UserManager manager;
	
	public UserAction() {
		manager = new UserManager();
	}
	
	public void ajouter(HttpServletRequest request){
		String login= request.getParameter("login");
		String password = request.getParameter("pwd");
	
		User u = new User(login, password);
		manager.ajouter(u);
	}
	public void afficher(HttpServletResponse response) throws IOException{
		List<User> users = manager.afficher();
		PrintWriter out = response.getWriter();
		for (int i = 0; i < users.size(); i++) {
			out.println(users.get(i));
		}
	}
	public void supprimer(HttpServletResponse response) throws IOException{
		PrintWriter out = response.getWriter();
		out.println("C'est une page de suppression");
	}
	public void modifier(HttpServletResponse response) throws IOException{
		PrintWriter out = response.getWriter();
		out.println("C'est une page de modification");
	}

}
